package edu.cuit.canary.service.bean;

import edu.cuit.canary.mapper.UserMapper;
import edu.cuit.canary.po.User;
import edu.cuit.canary.service.UserService;
import edu.cuit.canary.vo.UserVo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class UserServiceBean implements UserService {
    @Resource private UserMapper mapper;
    @Override
    public UserVo findById(Integer id) {
        var user = mapper.selectById(id);
        //将user对象属性填充进userVo对象属性(1.手工设置 userVo.setId(user.getId); 2.BeanUtils(1.内部使用反射,性能较低; 2.如果属性名不能完成填充); 3.mapstruct-使用插入式注解在编译阶段就生成了setter/getter,性能OK; 属性名不一致的情况也可以完成映射)
        return edu.cuit.canary.vo.mapper.UserMapper.INSTANCE.user2userVo(user);
    }
}
